﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MIPS_Simulator
{
    class InstructionMemory
    {
        private const long instMermorySize = 4294967296;
        private Dictionary<long, string> instMermory;
        
        public InstructionMemory()
        {
            instMermory = new Dictionary<long, string>();
        }

        public void storeWord(string data, long location)
        {
            if (location > instMermorySize || location < 0)
                throw new IndexOutOfRangeException("Memory index of of range");
            try
            {
                instMermory.Add(location, data);
            }
            catch (ArgumentException e)
            {
                instMermory[location] = data;
            }

        }

        public string loadWord(long location)
        {
            string value;
            
            if (location > instMermorySize || location < 0)
                throw new IndexOutOfRangeException("Memory index of of range");

            instMermory.TryGetValue(location, out value);
            return value;

        }
    }
}
